import requests
import re
import csv
header = {
    'referer': 'https://www.bilibili.com/video/BV1UY4y1e7ck?spm_id_from=333.1007.tianma.1-1-1.click',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36',
    'cookie':"登录后复制cookie",
}


def get_info(url):
    html = requests.get(url, headers=header)
    html.encoding = 'utf-8'
    data_list = re.findall(r':(.*?)@', html.text)
    # print(data_list)
    data_list = [i[1:] for i in data_list]
    print(data_list)


def main(cid,date):
    url = f'https://api.bilibili.com/x/v2/dm/web/history/seg.so?type=1&oid={cid}&date={date}'
    get_info(url=url)


if __name__ == '__main__':
    main(cid='444430708',date='2021-11-18')
